package top.codedance.iotp.client.plugins.async.bacnet;

import java.math.BigInteger;
import java.security.MessageDigest;

public class SubscribeParam {
    private String tag;
    private int subscriberProcess;
    private int deviceId;
    private int property;
    private int datatype;
    private int dataInstance;
    private int instanceId;
    private String clientId;

    public SubscribeParam() { }

    public SubscribeParam(String tag, int subscriberProcess, int deviceId, int property, int datatype, int instance, String clientId, int instanceId) {
        this.tag = tag;
        this.subscriberProcess = subscriberProcess;
        this.deviceId = deviceId;
        this.property = property;
        this.datatype = datatype;
        this.dataInstance = instance;
        this.clientId = clientId;
        this.instanceId = instanceId;
    }

    public String md5(){
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update((tag + deviceId + property + datatype + dataInstance + clientId + instanceId).getBytes());
            return new BigInteger(1, md5.digest()).toString(16);
        } catch (Exception e){
            return null;
        }
    }

    public String getTag() {
        return tag;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    public int getSubscriberProcess() {
        return subscriberProcess;
    }

    public void setSubscriberProcess(int subscriberProcess) {
        this.subscriberProcess = subscriberProcess;
    }

    public int getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(int deviceId) {
        this.deviceId = deviceId;
    }

    public int getProperty() {
        return property;
    }

    public void setProperty(int property) {
        this.property = property;
    }

    public int getDatatype() {
        return datatype;
    }

    public void setDatatype(int datatype) {
        this.datatype = datatype;
    }

    public int getDataInstance() {
        return dataInstance;
    }

    public void setDataInstance(int dataInstance) {
        this.dataInstance = dataInstance;
    }

    public String getClientId() {
        return clientId;
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public int getInstanceId() {
        return instanceId;
    }

    public void setInstanceId(int instanceId) {
        this.instanceId = instanceId;
    }
}
